#ifndef Properties_H
#define Properties_H

#include "QuestionDetails.h"
#include "ConstraintDetails.h"

namespace Xps
{
	class Properties : public QWidget
	{

	public:
		QLabel* ns;
		ConstraintDetails* cd;
		QuestionDetails* qd;
		XpsAssets::AssetManager* am;
		
		Properties(XpsAssets::AssetManager* am, QWidget* parent = 0) : QWidget(parent)
		{
			this->am = am;

			setWindowTitle("Item Properties");
			setWindowFlags(Qt::Tool);
			cd = new ConstraintDetails(am);
			qd = new QuestionDetails();
			ns = new QLabel("Nothing Selected");

			ns->setAlignment(Qt::AlignCenter);
			
			setLayout(new QVBoxLayout());
			layout()->setMargin(0);
			layout()->setSpacing(0);
			layout()->addWidget(ns);
			layout()->addWidget(cd);
			layout()->addWidget(qd);
			
			cd->hide();
			qd->hide();
		}

		void setItem(int count, Item* item = NULL)
		{
			cd->hide();
			qd->hide();
			ns->hide();

			if (item == NULL)
			{
				if (count == 0)
				{
					ns->setText("Nothing Selected");
				}
				else
				{
					ns->setText(QString("%1 Items Selected.").arg(count));
				}
				ns->show();
				return;
			}

			if (item->getType() == XpsAssets::TreeNode::CONSTRAINT)
			{
				cd->setItem(item);
				cd->show();
			}
			else if  (item->getType() == XpsAssets::TreeNode::QUESTION)
			{
				Tree::QuestionItem* qi = (Tree::QuestionItem*) item;
				qd->text->setText(am->getQuestion(qi->questionid)->text());
				qd->show();
			}
		}
	};
}
#endif